package com.yz.task;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class SimpleTask {
	@Autowired 
	private MyTask myTask;
	
	//@Autowired //自动装载，从spring容器中取一个对象
	//SimpleDateFormat datatimeFormat;
	
	 // @Scheduled(fixedRate=1000*5) // 每 隔 五 秒 
	  //public void pringInfo() {
		//  myTask.task1();
		 // System.out.println("于万伟准备5秒刷新一次"+datatimeFormat.format(new Date())); 
	 // }
	 
	
	
	@Scheduled(cron = "0 0 0 * * ?")
	public void printInfo() {
		myTask.task();
		System.out.println("明天0点执行"+new Date());
	}
	
	/*
	 * @Scheduled(cron = "0 41 16 ? * *") public void printInfo2() {
	 * System.out.println("于万伟准备5秒刷新一次"+new Date()); }
	 */
}
